package com.upb.webserver.common.pojo.application;

import cn.hutool.core.util.ObjectUtil;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.upb.webserver.common.pojo.base.RspBaseCreatorVO;
import com.upb.webserver.common.pojo.chain.BaseRspChainVO;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.util.Date;

@Data
@EqualsAndHashCode(callSuper = true)
public class RspApplicationVO extends RspBaseCreatorVO implements Comparable{
    private Integer id;
    private String remoteId;
    private Integer workOrderId;
    private Integer chainId;
    private Byte chainType;
    private Byte encryptionId;
    private String chainName;
    private String name;
    private String nameZh;
    private String version;
    private Byte createStatus;
    private Boolean hadSelfCompleted; //开发者自己的提交状态，true已完成提交，false未完成提交
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date gmtCreate;
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date gmtModified;
    private String description;

    @Override
    public int compareTo(Object o) {
        if (o instanceof RspApplicationVO) {
            RspApplicationVO s = (RspApplicationVO) o;
            if (ObjectUtil.hasEmpty(this.gmtModified, s.getGmtModified())) {
                return -1;
            }
            if (this.gmtModified.after(s.getGmtModified())) {
                return -1;
            } else if (this.gmtModified.equals(s.getGmtModified())) {
                return 0;
            } else {
                return 1;
            }
        }
        return 0;
    }
}
